import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/RegisterView.vue')
  },
  {
    path: '/home/dashboard',
    name: 'Dashboard',
    component: () => import('@/views/Dashboard.vue'),
    children: [
      {
        path: '/home',
        name: 'Home',
        component: Home,
        meta: { title: '首页', icon: ['fas', 'house-user'], top: true }
      },
      {
        path: '/info',
        name: 'Info',
        component: () => import('@/views/Info.vue')
      },

      

      // 用户管理
      {
        path: '/user-management',
        name: 'UserManagement',
        meta: { 
          title: '用户管理', 
          icon: ['fas', 'users'],
          top: true
        },
        children: [
          //用户列表
          {
            path: 'user-list',
            name: 'UserList',
            component: () => import('@/views/user-management/UserList.vue'),
            meta: { 
              title: '用户列表', 
              icon: ['fas', 'list'] 
            }
          },
          //用户注册信息审核
          {
            path: 'review-info',
            name: 'ReviewInfo',
            component: () => import('@/views/user-management/ReviewInfo.vue'),
            meta: { 
              title: '审核注册信息', 
              icon: ['fas', 'users-between-lines'] 
            }
          },
          //查看用户发布的商品
          {
            path: 'view-items',
            name: 'ViewItems',
            component: () => import('@/views/user-management/ViewItems.vue'),
            meta: { 
              title: '查看用户发布的商品', 
              icon: ['fas', 'right-to-bracket'] 
            }
          },
        ]
      },

      //物品管理
      {
        path: '/item-management',
        name: 'ItemManagement',
        meta: { 
          title: '商品管理', 
          icon: ['fas', 'sitemap'],
          top: true
        },
        children: [
          //物品列表
          {
            path: 'item-list',
            name: 'ItemList',
            component: () => import('@/views/item-management/ItemList.vue'),
            meta: { 
              title: '物品列表', 
              icon: ['fas', 'diagram-project'] 
            }
          },
          //物品审核
          {
            path: 'review-items',
            name: 'ReviewItems',
            component: () => import('@/views/item-management/ReviewItems.vue'),
            meta: { 
              title: '审核物品',
              icon: ['fas', 'briefcase'] 
            }
          },
          //物品分类
          {
            path: 'items-category',
            name: 'ItemsCategory',
            component: () => import('@/views/item-management/ItemsCategory.vue'),
            meta: { 
              title: '物品分类',
              icon: ['fas', 'briefcase'] 
            }
          }
        ]
      },
      
      // 交易管理
      {
        path: '/transaction-management',
        name: 'TransactionManagement',
        meta: { 
          title: '交易管理', 
          icon: ['fas', 'screwdriver-wrench'],
          top: true
        },
        children: [
          //交易流程跟踪
          {
            path: 'transaction-process-tracking',
            name: 'TransactionProcessTracking',
            component: () => import('@/views/transaction-management/TransactionProcessTracking.vue'),
            meta: { 
              title: '交易流程跟踪', 
              icon: ['fas', 'arrow-up-from-bracket'] 
            }
          },
        ]
      },

      // 信息反馈
      {
        path: '/message',
        name: 'Message',
        meta: { 
          title: '留言', 
          icon: ['fas', 'user-shield'],
          top: true
        },
        //用户留言
        children: [
          {
            path: 'user-message',
            name: 'UserMessage',
            component: () => import('@/views/message/UserMessage.vue'),
            meta: { 
              title: '用户留言', 
              icon: ['fas', 'id-card'] 
            }
          }
        ]
      },
      
      //数据统计
      {
        path: '/data-statistics',
        name: 'DataStatistics',
        meta: { 
          title: '数据统计', 
          icon: ['fas', 'code'],
          top: true
        },
        //数据图表
         children: [
          {
            path: 'data-charts',
            name: 'DataCharts',
            component: () => import('@/views/data-statistics/DataCharts.vue'),
            meta: { 
              title: '数据图表', 
              icon: ['fas', 'id-card'] 
            }
          }
        ]
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router